<?php
namespace app\admin\controller;
use think\Db;
use think\Request;

class Template extends Common
{
    //酒店设置
    public function index(){
        if(request()->isPost()) {
			$time = input('post.time');
            $key = input('post.key');
			$where=array();	
			if($key){
				$where['title'] = ['like','%'.$key.'%'];
			}
            $page =input('page')?input('page'):1;
            $pageSize =input('limit')?input('limit'):config('common.page_sizes');
            $list = db('smg_reply')
                ->where($where)
                ->order('id desc')
                ->paginate(array('list_rows'=>$pageSize,'page'=>$page))
                ->toArray();
			$list = model('smgReply')->listAddTimeInfo($list);	
			return $result = ['code'=>0,'msg'=>config('common.data_success'),'data'=>$list['data'],'count'=>$list['total'],'rel'=>1];
		}
        return $this->fetch('');
    }
 public function edit(){
        if(request()->isPost()){
            $data = input('post.');
            return model('smgReply')->commonData($data,'修改成功!','修改失败，请重试!');
        }else{
            $id = input('id');
            $list =db('smg_reply')->where(['id'=>$id])->find();
            return $this->fetch('',['list'=>$list]);
        }
        
    }
    public function message(){
        if(request()->isPost()) {
			$time = input('post.time');
            $key = input('post.key');
			$where=array();	
			if($key){
				$where['title'] = ['like','%'.$key.'%'];
			}
            $page =input('page')?input('page'):1;
            $pageSize =input('limit')?input('limit'):config('common.page_sizes');
            $list = db('message')
                ->where($where)
                ->order('id desc')
                ->paginate(array('list_rows'=>$pageSize,'page'=>$page))
                ->toArray();
			$list = model('message')->listAddTimeInfo($list);	
			return $result = ['code'=>0,'msg'=>config('common.data_success'),'data'=>$list['data'],'count'=>$list['total'],'rel'=>1];
		}
        return $this->fetch('');
    }
 public function messageedit(){
        if(request()->isPost()){
            $data = input('post.');
            return model('message')->commonData($data,'修改成功!','修改失败，请重试!');
        }else{
            $id = input('id');
            $list =db('message')->where(['id'=>$id])->find();
            return $this->fetch('',['list'=>$list]);
        }
        
    }



}
